﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Framework.Configuration
{
	public class ClientConfiguration:IClientConfiguration
	{
		public ClientConfiguration() {

		}

		/// <summary>
		/// 服务器端口
		/// </summary>
        public int ToPort { get { return toPort; } set { toPort=value; } }
		/// <summary>
		/// 服务地址
		/// </summary>
        public string ToIPAddress { get { return toIPAddress.ToString(); } set { SetIPaddress(value); } }

		/// <summary>
		/// 需要备份的目录
		/// </summary>
		public List<string> BackupsDirectorys { get { return backupsDirectorys; } set { backupsDirectorys = value; } }

	    public List<Schedule> Schedules { get { return schedules; } set { schedules = value; } }
	    public List<string> BackupsDBCommands { get { return backupsDBCommands; } set { backupsDBCommands = value; } }


		public void SetIPaddress(string ipaddress)
		{
			if (IPAddress.TryParse(ipaddress,out IPAddress ip))
			{
				toIPAddress = ip;
			}
			else
			{
				throw new InvalidOperationException("不合法的ip地址!");
			}
		}



		private int toPort;		
		private IPAddress toIPAddress;		
		private List<string> backupsDirectorys;
		private List<string> backupsDBCommands;
		private List<Schedule> schedules;
	}
}
